package com.ruoyi.web.controller.house;

import com.ruoyi.system.domain.Equipment;
import com.ruoyi.system.domain.dto.HouseChangeStateDto;
import com.ruoyi.system.domain.dto.HouseQueryDto;
import com.ruoyi.system.domain.vo.HouseInfoVo;
import com.ruoyi.system.domain.vo.HouseMapVo;
import com.ruoyi.system.service.IHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("house/house")
public class HouseController {

    @Autowired
    private IHouseService houseService;

    @PostMapping("/list")
    public Map getHousetList(@RequestBody HouseQueryDto dto) {
        return houseService.selectHouseList(dto);
    }

    @GetMapping("/{houseId}")
    public HouseInfoVo getHouseInfo(@PathVariable("houseId") String houseId) {
        return houseService.findHouseInfo(houseId);
    }

    @PostMapping("/changeStates")
    public void changeHouseStates(@RequestBody HouseChangeStateDto dto) throws IOException {
        houseService.changeHouseState(dto);
    }

    @GetMapping("/getHouseMap")
    public List<HouseMapVo> getHouseMap() {
        List<HouseMapVo> houseMaps = houseService.getHouseMaps();
        return houseMaps;
    }

}
